package tests;

import static org.junit.Assert.*;

import org.junit.Test;

import coreAlgorithm.Bit;



public class BitTest {


	@Test
	public void testGetValue() {
		Bit bit0 = new Bit(0);
		Bit bit1 = new Bit(1);
		assertEquals(0, bit0.getValue());
		assertEquals(1, bit1.getValue());
		try {
			new Bit(2);
		} catch (IllegalArgumentException e) {
			// that's ok
		}
	}

	@Test
	public void testSetValue() {
		Bit bit = new Bit(0);
		bit.setValue(1);
		assertEquals(1, bit.getValue());

		try {
			bit.setValue(-1);
		} catch (IllegalArgumentException e) {
			// that's ok
		}
	}

	@Test
	public void testEqualsBit() {
		assertEquals(new Bit(0), new Bit(0));
		assertTrue(new Bit(1).equals(new Bit(1)));

		assertNotSame(new Bit(1), new Bit(0));
		assertNotSame(new Bit(0), new Bit(1));
		assertFalse(new Bit(0).equals("no Bit"));
	}
	
	@Test
	public void testHashCode() throws Exception {
		assertNull(null);
		Bit x = null;
		assertNull(x);
		
		assertEquals(1, new Bit(1).hashCode());
		assertEquals(0,	new Bit(0).hashCode());
	}

}
